/**
 * File name: ARFFFileBranchWriter.java Author: Willard Wang Create date: Jul
 * 28, 2013
 */
package edu.sjtu.se.prophet.io;

import java.util.List;

import edu.sjtu.se.prophet.graph.Branch;
import edu.sjtu.se.prophet.graph.Bucket;
import edu.sjtu.se.prophet.graph.Graph;
import edu.sjtu.se.prophet.utils.GraphUtil;

/**
 * @author deathspeeder
 * 
 */
public class ARFFFileBranchWriter extends AbstractARFFBucketWriter {
    public ARFFFileBranchWriter() {
        outFileName = "data-branch.arff";
        arffName = "branches";
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getComment(edu.sjtu.se
     * .prophet.graph.Bucket)
     */
    @Override
    protected String getComment(Bucket bucket) {
        return bucket.toString();
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getBuckets(edu.sjtu.se
     * .prophet.graph.Graph)
     */
    @Override
    protected List<Branch> getBuckets(Graph graph) {
        return GraphUtil.generateBranch(graph);
    }

    // /*
    // * (non-Javadoc)
    // *
    // * @see edu.sjtu.se.prophet.io.AbstractARFFFileWriter#writeData()
    // */
    // @Override
    // protected void writeData() throws IOException {
    // br.append("@DATA\n");
    // for (Graph graph : graphs) {
    // for (Branch branch : GraphUtil.generateBranch(graph)) {
    // StringBuffer buffer = new StringBuffer();
    // for (int i = 0; i < VALID_METRICS.length; i++) {
    // buffer.append(branch.getAverageMetric(VALID_METRICS[i]));
    // buffer.append(",");
    // }
    // buffer.append(getLevel(branch
    // .getAverageMetric(IOCommon.BUG_COUNT)));
    // br.append(buffer.toString() + " % " + branch + "\n");
    // }
    // }
    // }

}
